Repository navigation
Conversation
|
There should probably be a trac ticket for this PR. Please create it, or ask us to create it. Then the PR title should be updated. |
For 'arr[i]' where arr is an array of pointers, isDecayedPointer() returned true because the type of 'arr[i]' is a pointer. A lifetime value was then created and forwarded for each subscript; with many 'arr[N] = ...' statements in one function this is quadratic. spice rop3.c: ValueFlow 352s => 28s. In 10000 Debian packages (--check-level=exhaustive) this adds 11 warnings: 9 correct nullPointerOutOfMemory/nullPointerOutOfResources and 2 false positives (uninitvar, arrayIndexOutOfBoundsCond). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d1ed991 to
396bb75
Compare
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no new problems. When the array is the left operand of [, isDecayedPointer() now returns false. That fixes the quadratic slowdown: a function with 3000 arr[i] = "..." statements took 105 s with base and 0.36 s with the PR. I compared the PR with base on many lifetime, dangling-pointer, uninitvar and multi-dimensional-array cases (a[0] of int a[2][3]) and on test/cfg, samples, externals, cli, gui and tools. The results were the same everywhere. I could not reproduce the 2 false positives that the description reports from the Debian run.
Testing
-
I built
cppcheckandtestrunnerin bothpr/andbase/. -
The full
./testrunner -qpasses: 5419 tests, 0 failures. -
I copied the PR's
test/testvalueflow.cppinto base. The new assertion fails there, at line 845 (expected 0, got 1). So the test covers the change. -
Performance: generated
void f(void){ const char *arr[3000]; arr[0]="s0"; ... arr[2999]="s2999"; }and rancppcheck -q perf.c. It took 1m44.9s with base and 0.36s with the PR. -
Behaviour: I wrote scratch files covering:
- returning or storing
a[0]of 2D arrays in C and C++ (std::string_view,std::vector<int*>) &a[i]aliases followed by uninit reads- use after scope of
p = a[0]andp = &a[1] p = a[0] + 1- pointer arrays filled from
mallocand then dereferenced
Output from base and PR was identical. Some false negatives and one existing uninitvar false positive (
&a[0].x) are already present in base, so the PR did not cause them. - returning or storing
-
Corpus comparison: ran base and PR on
test/cfgandsamples(exhaustive check level,--enable=warning,style --inconclusive) and onexternals cli gui/*.cpp tools. There was no difference in the warnings.
Automated review of 396bb75 by Claude. The pull request was built and tested locally.
For 'arr[i]' where arr is an array of pointers, isDecayedPointer() returned true because the type of 'arr[i]' is a pointer. A lifetime value was then created and forwarded for each subscript; with many 'arr[N] = ...' statements in one function this is quadratic.
spice rop3.c: ValueFlow 352s => 28s.
In 10000 Debian packages (--check-level=exhaustive) this adds 11 warnings: 9 correct nullPointerOutOfMemory/nullPointerOutOfResources and 2 false positives (uninitvar, arrayIndexOutOfBoundsCond).